package com.zzyl.nursing.service.impl;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzyl.nursing.mapper.ArtifactLoanMapper;
import com.zzyl.nursing.domain.ArtifactLoan;
import com.zzyl.nursing.service.IArtifactLoanService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 文物出借管理，用于跟踪和管理文物的出借情况Service业务层处理
 *
 * @author success
 * @date 2025-03-21
 */
@Service
public class ArtifactLoanServiceImpl extends ServiceImpl<ArtifactLoanMapper, ArtifactLoan> implements IArtifactLoanService {
    @Autowired
    private ArtifactLoanMapper artifactLoanMapper;

    /**
     * 查询文物出借管理，用于跟踪和管理文物的出借情况
     *
     * @param loanId 文物出借管理，用于跟踪和管理文物的出借情况主键
     * @return 文物出借管理，用于跟踪和管理文物的出借情况
     */
    @Override
    public ArtifactLoan selectArtifactLoanByLoanId(Integer loanId) {
        return artifactLoanMapper.selectArtifactLoanByLoanId(loanId);
    }

    /**
     * 查询文物出借管理，用于跟踪和管理文物的出借情况列表
     *
     * @param artifactLoan 文物出借管理，用于跟踪和管理文物的出借情况
     * @return 文物出借管理，用于跟踪和管理文物的出借情况
     */
    @Override
    public List<ArtifactLoan> selectArtifactLoanList(ArtifactLoan artifactLoan) {
        return artifactLoanMapper.selectArtifactLoanList(artifactLoan);
    }

    /**
     * 新增文物出借管理，用于跟踪和管理文物的出借情况
     *
     * @param artifactLoan 文物出借管理，用于跟踪和管理文物的出借情况
     * @return 结果
     */
    @Override
    public int insertArtifactLoan(ArtifactLoan artifactLoan) {
        artifactLoan.setLoanDate(LocalDateTime.now());
        return artifactLoanMapper.insert(artifactLoan);
    }

    /**
     * 修改文物出借管理，用于跟踪和管理文物的出借情况
     *
     * @param artifactLoan 文物出借管理，用于跟踪和管理文物的出借情况
     * @return 结果
     */
    @Override
    public int updateArtifactLoan(ArtifactLoan artifactLoan) {
        return artifactLoanMapper.updateArtifactLoan(artifactLoan);
    }

    /**
     * 批量删除文物出借管理，用于跟踪和管理文物的出借情况
     *
     * @param loanIds 需要删除的文物出借管理，用于跟踪和管理文物的出借情况主键
     * @return 结果
     */
    @Override
    public int deleteArtifactLoanByLoanIds(Integer[] loanIds) {
        return artifactLoanMapper.deleteArtifactLoanByLoanIds(loanIds);
    }

    /**
     * 删除文物出借管理，用于跟踪和管理文物的出借情况信息
     *
     * @param loanId 文物出借管理，用于跟踪和管理文物的出借情况主键
     * @return 结果
     */
    @Override
    public int deleteArtifactLoanByLoanId(Integer loanId) {
        return artifactLoanMapper.deleteArtifactLoanByLoanId(loanId);
    }
}
